{% extends "shop/base.html" %}

{% load static %}

{% block title %}
    {% if category %}{{ category.title }}{% else %}商品{% endif %}
{% endblock %}

{% block content %}
    <div class="product-detail">
        <img src="{% if product.image %}{{ product.image.url }}{% else %}{% static "img/no_image.png" %}{% endif %}">
        <h1>{{ product.name }}</h1>
        <h2><a href="{{ product.category.get_absolute_url }}">{{ product.category }}</a></h2>
        <p class="price">${{ product.price }}</p>
        {{ product.description|linebreaks }}
    </div>

    <p class="price">${{ product.price }}</p>
    <form action="{% url "cart:cart_add" product.id %}" method="post">
        {{ cart_product_form }}{% csrf_token %}
        <input type="submit" value="添加到购物车">
    </form>
{% endblock %}